﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace 计科2111林开心
{
    public partial class _1_7 : System.Web.UI.Page
    {
       
        protected void Page_Load(object sender, EventArgs e)
        {
            for (int i = DateTime.Now.Year - 30; i < 2023; i++)
            {
                DropDownList1.Items.Add("" + i);

            }
          
            for (int i = 1; i < 13; i++)
            {
                DropDownList2.Items.Add("" + i);

            }

          
        }

    

        protected void DropDownList2_TextChanged(object sender, EventArgs e)
        {
           if(DropDownList2.SelectedItem.Text=="2")
                   if ((Convert.ToInt32(DropDownList1.Text) % 4 == 0 && Convert.ToInt32(DropDownList1.Text) % 100 != 0)|| (Convert.ToInt32(DropDownList1.Text) % 400 == 0))
                     for (int i = 1; i <= 29; i++)
                   {
                       DropDownList3.Items.Add("" + i);
                   }
                     else
                       for (int i = 1; i <= 28; i++)
                   {
                       DropDownList3.Items.Add("" + i);
                   }
           else 
                      switch (DropDownList2.SelectedIndex)
                  {
                      case 0:
                      case 2:
                      case 4:
                      case 6:
                      case 11:
                      case 7:
                      case 9:
                          DropDownList3.Items.Clear();
                          for (int i = 1; i <= 31; i++)
                          {
                              DropDownList3.Items.Add(""+i);
                          }
                          break;
                      case 3:
                      case 5:
                      case 8:
                      case 10:
                          DropDownList3.Items.Clear();
                          for (int i = 1; i <= 30; i++)
                          {
                              DropDownList3.Items.Add("" + i);
                          }
                          break;

            }
        }
        public Table tb = new Table();
        protected void Button1_Click(object sender, EventArgs e)
        {


           
            tb = Table1;
            TableRow tbrow = new TableRow();
                TableCell tbcell1 = new TableCell();
                TableCell tbcell2 = new TableCell();
                TableCell tbcell3 = new TableCell();
                
            tbcell1.Text = DropDownList1.SelectedValue + "年";
            tbrow.Cells.Add(tbcell1);

            tbcell2.Text = DropDownList2.SelectedValue + "月";
            tbrow.Cells.Add(tbcell2);

            tbcell3.Text = DropDownList3.SelectedValue + "日";
            tbrow.Cells.Add(tbcell3);

            Table1.Rows.Add(tbrow);
            tb.Rows.Add(tbrow);
            Table1 = tb;




        }
    }
}